export default {
  set (name, value, days) {
    var d = new Date()
    if (!days) {
      // 默认30天
      d.setTime(d.getTime() + 24 * 60 * 60 * 1000 * 30)
    } else {
      d.setTime(d.getTime() + 24 * 60 * 60 * 1000 * days)
    }
    window.document.cookie = name + '=' + value + ';path=/;expires=' + d.toGMTString()
  },
  get (name) {
    var v = window.document.cookie.match('(^|;) ?' + name + '=([^;]*)(;|$)')
    return v ? v[2] : null
  },
  delete (name) {
    this.set(name, '', -1)
  }
}
